﻿<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE xsl:stylesheet  [
    <!ENTITY nbsp   "&#160;">
    <!ENTITY copy   "&#169;">
    <!ENTITY reg    "&#174;">
    <!ENTITY trade  "&#8482;">
    <!ENTITY mdash  "&#8212;">
    <!ENTITY ldquo  "&#8220;">
    <!ENTITY rdquo  "&#8221;">
    <!ENTITY pound  "&#163;">
    <!ENTITY yen    "&#165;">
    <!ENTITY euro   "&#8364;">
]>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:import href="mainframe.xsl"/>
    <xsl:template name="main">

        <h1>App List</h1>
        <table border="1" cellpadding="4" cellspacing="0">
            <tr>
                <th>ID</th>
                <th>App</th>
                <th>创建日期</th>
                <th>操作</th>
            </tr>
            <xsl:for-each select="/root/app">
                <tr>
                    <td>
                        <xsl:value-of select="id"/>
                    </td>
                    <td>
                        <xsl:value-of select="name"/>
                    </td>
                    <td>
                        <xsl:value-of select="datecreated"/>
                    </td>
                    <td>
                        <a href="?app={id}&amp;action=buildapp">管理</a>&nbsp;
                        <a href="javascript:void(0)" onclick="BackDb('{id}',this)">备份</a>&nbsp;
                        <a href="javascript:void(0)" onclick="MemeryUsed('{id}',this)">占用内存</a>&nbsp;
                        <a href="javascript:void(0)" onclick="DiskUsed('{id}',this)">占用磁盘</a>
                    </td>
                </tr>
            </xsl:for-each>
        </table>
            
        
    </xsl:template>

    <xsl:template name="js">
        <script type="text/javascript">
            <xsl:comment>
                function DiskUsed(app,obj){
                $.get("?app="+app+"&amp;action=diskused", function(x){
                alert(x);
                });
                }
                function MemeryUsed(app,obj){
                $.get("?app="+app+"&amp;action=memeryused", function(x){
                alert(x);
                });
                }
                function BackDb(app,obj){
                if(!confirm("确定要开始备份此APP("+app+")的数据库与配置文件吗？\r\n\r\n过程可能会比较慢，请耐心等候。")) return;
                $.get("?app="+app+"&amp;action=backup", function(x){
                eval("var json="+x);
                alert("备份成功！\r\n\r\n生成压缩文件耗时："+(json["totaltime"]/1000)+"秒\r\n生成压缩文件体积："+(json["filesize"]/1024)+"Kb");
                });
                }
            </xsl:comment>
        </script>
    </xsl:template>
</xsl:stylesheet>